const app = getApp();
Page({
  data: {
    cndUrl: app.domainName,
    ctx:"",
    color:"black",
    mouse_x:0,
    mouse_y:0,
    mouseX:0,
    mouseY:0,
    colorArr:["red","orange","yellow","green","cyan","blue","purple"],
    type:"line",
  },
  onLoad: function (options) {
    this.ctx = wx.createCanvasContext("board");
    //设置线条颜色
    this.ctx.setStrokeStyle("black");
    //设置线条粗细
    this.ctx.setLineWidth(5);

  },
  onUnload: function () {

    this.ctx = null;
    this.color=null;
    this.mouse_x=null;
    this.mouse_y=null;
    this.mouseX=null;
    this.mouseY=null;
    this.type=null
  },
  start:function(ev){

   this.mouse_x = ev.touches[0].x;
   this.mouse_y = ev.touches[0].y; 
   this.ctx.moveTo(this.mouse_x,this.mouse_y)
   

 },
 move: function (ev) {
  this.mouseX = ev.touches[0].x;
  this.mouseY = ev.touches[0].y;
    
  //设置终点  鼠标当前移动的位置
  this.ctx.lineTo(this.mouseX, this.mouseY);
  
  this.ctx.stroke();
  this.ctx.draw(true)

  this.ctx.moveTo(this.mouseX, this.mouseY);
  


},
end:function(ev){

  var x1 = this.mouse_x;
  var y1 = this.mouse_y;
  var x2 = this.mouseX;
  var y2 = this.mouseY;
   
},
size:function(e){
  var that = this;
  let value = e.detail.value;
  
  that.ctx.setLineWidth(value);
},

wrap:function(){

  this.ctx.setStrokeStyle("#edeef3");
  this.ctx.setLineWidth(10);
},

  onShareAppMessage: function () {

  }
})